from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.specsSerializers import specsserializers, Spuserializer
from goods.models import SPU, SPUSpecification
from meiduo_admin.utils import LargeResultsSetPagination


# 规格表妲增删改查
class specsView (ModelViewSet):
    serializer_class = specsserializers
    queryset = SPUSpecification.objects.all ()
    pagination_class = LargeResultsSetPagination

    # 为新增商品查询spu商品下拉列表
    def simple(self, request):
        # 1,查询数据
        spus = SPU.objects.all ()

        # 2,序列化返回
        ser = Spuserializer (spus, many=True)
        return Response (ser.data)
